package com.wanshun;


import com.wanshun.common.utils.AESUtils;
import org.junit.Test;

import java.io.*;

public class MyTest {
    public static void main(String[] args) throws Exception {
//        String name = AESUtils.decrypt("SXGfpsHF5n/zuCBzHzGsGQ==");
//        System.out.println("name="+name);


        /*BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp04.csv"));

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp04-2.csv"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",");

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }
                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
        }

        br.close();*/
        // driver_carnums_20210219_tmp05
        //driver_brandmodelid_20210219_tmp04();
        //driver_brandmodelid_20210219_tmp05();
        //driver_carnums_20210219_tmp04();
        // driver_carnums_20210219_tmp05();
        //driver_carnums_20210219_tmp044();
        driver_carids_20210218_tmp04();
    }



    public static void driver_brandmodelid_20210219_tmp05() throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp05.csv"));

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp05-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }
                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }



    public static void driver_brandmodelid_20210219_tmp04() throws Exception {
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp04.csv"));

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp04-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }
                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }

    public static void driver_carnums_20210219_tmp04() throws Exception {
        //BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp04.csv"));
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp04.csv"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv")));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"gbk"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"utf-8"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\i.csv"),"gbk"));
        //new InputStreamReader(new FileInputStream(""),"utf-8");

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp04-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }


                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }


    public static void driver_carnums_20210219_tmp05() throws Exception {
        //BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp04.csv"));
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp05.csv"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv")));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"gbk"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"utf-8"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\i.csv"),"gbk"));
        //new InputStreamReader(new FileInputStream(""),"utf-8");

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp05-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }


                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }

    public static void driver_carnums_20210219_tmp044() throws Exception {
        //BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carnums_20210219_tmp04.csv"));
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_brandmodelid_20210219_tmp04.csv")));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"gbk"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp04.csv"),"utf-8"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp044.csv"),"gbk"));
        //new InputStreamReader(new FileInputStream(""),"utf-8");

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_brandmodelid_20210219_tmp04-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }


                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }






    public static void driver_carids_20210218_tmp04() throws Exception {
        //BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carids_20210218_tmp04.csv"));
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Downloads\\driver_carids_20210218_tmp04-2.txt"));

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\driver_carids_20210218_tmp04-2.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            //System.out.println(line);
            String[] arr = line.split(",");

            StringBuilder sb = new StringBuilder(); //存储一行写出去

           /* for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3 || i==4){
                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }
                sb.append(arr[i]).append(",");
            }*/
            // System.out.println(arr.length);
            if (arr.length!=14)
            {
                System.out.println(arr.length+"=>"+line);
            }
            //sb.append("\n"); //换行

            // System.out.println(sb); //打印一行看看
            // bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }


    @Test
    public void test1() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\a.csv")));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\driver_carnums_20210219_tmp044.csv"),"gbk"));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\\\Users\\\\DELL\\\\Downloads\\\\a.csv"),"utf-8"));

        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\DELL\\Downloads\\b.txt"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",");

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                if(i==2 || i==3){ //去除车牌号，后面补上
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }
                sb.append(arr[i]).append(",");
            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }

    @Test
    public void test2() throws Exception {
        String s = "imqpQqhAUf7D5lbX6kqzUA==";
//        String s1 = AESUtils.decrypt(s);
        System.out.println(s1);
    }


    @Test
    public void myTest() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\DELL\\Downloads\\cc.csv")));
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\DELL\\Downloads\\cc.csv"),"utf-8"));

        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:\\Users\\DELL\\Downloads\\cc-2.txt")));
        //BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("C:\\Users\\DELL\\Downloads\\cc-2.txt"),"utf-8"));

        String line = null;
        br.readLine(); //读表头
        while ((line= br.readLine())!=null) {
            System.out.println(line);
            String[] arr = line.split(",",-1);

            StringBuilder sb = new StringBuilder(); //存储一行写出去
            for (int i=0; i<arr.length; i++)
            {
                //解密
                if(i==0){
//                    sb.append(AESUtils.decrypt(arr[i])).append(",");
                    continue;
                }

                if(i==arr.length-1){ //最后一行不加,
                    sb.append(arr[i]);
                } else {
                    sb.append(arr[i]).append(",");
                }



            }
            sb.append("\n"); //换行

            System.out.println(sb); //打印一行看看
            bw.write(sb.toString()); //记得手动去文件加表头
        }

        bw.close();
        br.close();
    }



}
